package lab02.test17;

public class Test17 {
    public static void main(String[] args) {
        int min;
        int max;
        int j = 0;
        int k = 0;
        int A[] = {74, 484, 30, 17, 62};  // 声明整数数组A,并赋初值
        max = A[0];
        min = A[0];
        System.out.print("数组A的元素包括：");
        for (int i = 0; i < A.length; i++) {
            System.out.print(A[i] + " ");

            if (A[i] > max)   // 判断最大值
            {
                max = A[i];
                j = i + 1;
                //          System.out.println(j);
            }
            if (A[i] < min) {  // 判断最小值
                min = A[i];
                k = i + 1;
            }
        }
        System.out.println("\n数组的最大值在第" + j + "位" + "是：" + max); // 输出最大值
        System.out.println("数组的最小值在第" + k + "位" + "是：" + min); // 输出最小值
    }
}
